//一种简单的key

#ifndef KEY_H
#define KEY_H

#include "common.h"
#include "dev_prv.h"

enum {
    kKeyState_Released = 0,
    kKeyState_Pressed = 1,
};

typedef enum {
    kKeyValidLevel_High = 0,
    kKeyValidLevel_Low = 1,
}kKeyValidLevel_t;

typedef struct _key_t{
    void *bus_handle;
    key_bus_t *bus;
    
    debouncing_signal_t s;
    uint16_t valid_level:1; //有效电平
    uint16_t state:1; //按键状态
    uint16_t change:1; //状态变化
}key_t;

extern void key_init(key_t *t, uint16_t interval, uint8_t valid_level);
extern uint8_t key_scan(key_t *t, uint16_t tick);

#endif